home *** CD-ROM | disk | FTP | other *** search
- Path: rcp6.elan.af.mil!rscernix!root
- From: danpop@mail.cern.ch (Dan Pop)
- Newsgroups: comp.lang.c
- Subject: Re: String Upper/Lower--void main an error?
- Date: 20 Mar 96 15:23:28 GMT
- Organization: CERN European Lab for Particle Physics
- Message-ID: <root.827335408@rscernix>
- References: <4ifra6$52i@scipio.cyberstore.ca> <DoFA24.AL7@iquest.net> <4ii1nh$bng@castle.nando.net> <4ini70$8j@vodka.intele.net>
- NNTP-Posting-Host: ues5.cern.ch
- X-Newsreader: NN version 6.5.0 #7 (NOV)
-
- In <4ini70$8j@vodka.intele.net> cjmorgan@intele.net (Jason V. Morgan) writes:
-
- >>>void main (void) {
- >>
- >>Oh, please! Read the FAQ to avoid posting crap like this.
- >>
- >I don't thing that void main is really considered to be an error.
-
- Nobody cares about what you think. You were asked to read the FAQ
- _before_ emiting your (incompetent) opinions on this topic, which has
- been rehashed to death in this newsgroup.
-
- >Return
- >values are only really necessary if they're going to mean anything. It is
- >compilable (maybe I'm wrong and it's not portable).
-
- Yes, you _are_ wrong and it is "compilable" ONLY if your compiler decides
- to compile it, because it is not required to accept such garbage. My
- compiler doesn't:
-
- AxCrnA$ copy void.c tt:
- void main(void) {}
- AxCrnA$ cc void.c
-
- void main(void) {}
- .....^
- %CC-E-NEEDNONVOID, In this statement, "main(...)" has void type, but occurs in a
- context that requires a non-void result.
- at line number 1 in file DISK$L32:[DANPOP]VOID.C;1
-
- >At least it was declared
- >void so it didn't default to an int.
-
- And this is precisely the mistake! It is illegal to define main() as
- returning void.
-
- >You might as well say that it's an error
- >because argc, argv, and env weren't passed (to be honest, I'm not sure if env
- >is actually standard, I got it from the programmer's reference, not the
- >standard).
-
- You're 100% ignorant as far as this problem is concerned. argc and argv
- are _optional_ in the definition of main() and env has no business to be
- in the argument list of main(). Try to stick this in your head: the C
- language allows main() to have either two arguments (int and char**) or
- none. It also _requires_ main() to be defined as a function returning int.
- Otherwise, your program invokes undefined behaviour, and the programmer's
- reference for your compiler is completely irrelevant to this newsgroup.
- The C programming language is NOT defined by your compiler or its
- documentation.
-
- Dan
- --
- Dan Pop
- CERN, CN Division
- Email: danpop@mail.cern.ch
- Mail: CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
-